﻿namespace 
    ``Concerning the assertion syntax``

module 
    ``Strings``=
    open FSpec
    
    let ``it fail a string contains assertion``()=
        capture(fun()-> 

            "String" |> should.containTheString "str"

        ).Description 
        |> should.equal (format Resources.TheStringShouldContainTheSubstring_0_ ["str"])
        
    let ``it fail a string starts with assertion``()=
        capture(fun()->

            "String" |> should.startWith "str" 

        ).Description
        |> should.equal (format Resources.TheStringShouldStartWith_0_ ["str"])
        
    let ``it fail a string ends with assertion``()=
        capture(fun()->
            
            "String" |> should.endWith "str"

        ).Description
        |> should.equal (format Resources.TheStringShouldEndWith_0_ ["str"])
        
    let ``it fail a string match assertion``()=
        capture(fun()->
            
            "String" |> should.matchExpression "[\d+]"

        ).Description
        |> should.equal Resources.TheStringShouldMatchARegularExpression

    let ``it provide a case insensitive set of string assertions``()=
        "string" |> should.ignoreCase.equal "sTRinG"
        "string" |> should.ignoreCase.startWith "STR"
        "string" |> should.ignoreCase.endWith "RING"
        "string" |> should.ignoreCase.contain "TRI"
        "string" |> should.ignoreCase.matchExpression "\w?"

    let ``it fail a case insensitive equals``()=
        capture(fun()->
            "string" |> should.ignoreCase.equal "234"
        )

    let ``it fail a case insensitive contains``()=
        capture(fun()->
            "string" |> should.ignoreCase.contain "234"
        )

    let ``it fail a case insensitive startsWith``()=
        capture(fun()->
            "string" |> should.ignoreCase.startWith "23"
        )

    let ``it fail a case insensitive endsWith``()=
        capture(fun()->
            "string" |> should.ignoreCase.endWith "23"
        )

    
    let ``it fail a case insensitive regex match``()=
        capture(fun()->
            "string" |> should.ignoreCase.matchExpression "$\d*^"
        )

    let ``it provide a case insensitive set of negative string assertions``()=
        "string" |> shouldNot.ignoreCase.equal "fubar"
        "string" |> shouldNot.ignoreCase.startWith "ING"
        "string" |> shouldNot.ignoreCase.endWith "STR"
        "string" |> shouldNot.ignoreCase.contain "FUBAR"
        "string" |> shouldNot.ignoreCase.matchExpression "$^"

    let ``it fail a case insensitive notEquals``()=
        capture(fun()->
            "string" |> shouldNot.ignoreCase.equal "STRING"
        )

    let ``it fail a case insensitive notContains``()=
        capture(fun()->
            "string" |> shouldNot.ignoreCase.contain "TRI"
        )

    let ``it fail a case insensitive notStartWith``()=
        capture(fun()->
            "string" |> shouldNot.ignoreCase.startWith "STR"
        )

    let ``it fail a case insensitive notEndWith``()=
        capture(fun()->
            "string" |> shouldNot.ignoreCase.endWith "InG"
        )
    
    let ``it fail a case insensitive regex mismatch``()=
        capture(fun()->
            "string" |> shouldNot.ignoreCase.matchExpression "STRING"
        )


        
